package com.itmck.control;

import com.itmck.dto.User;
import com.itmck.dto.response.ApiResultResponse;
import com.itmck.feign.ProductFeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 太阳当空照,花儿对我笑
 * <p>
 * Create by M ChangKe 2021/11/2 20:50
 **/
@Slf4j
@RestController
public class OrderController {


    @Resource
    private ProductFeignClient productFeignClient;

    @GetMapping("/order/getOrder")
    public ApiResultResponse<String> getOrder(@RequestParam String name) {

        log.info("模拟feign进行接口调用,入参:{}", name);
        String result = productFeignClient.getProduct(name);
        log.info("响应:{}", result);
        return ApiResultResponse.ok(result);
    }

    @PostMapping("/order/getProductUser")
    public ApiResultResponse<User> getProductUser(@RequestBody User user) {
        log.info("请求参数:{}", user);
        User productUser = productFeignClient.getProductUser(user);
        log.info("响应:{}", productUser);
        return ApiResultResponse.ok(productUser);
    }

}